<template>
  <div class="commentItem">
    <item
      v-if="parent.parent"
      :parent="parent.parent"
      @sentcom="replycom"
    ></item>
    <div class="top">
      <div class="left">
        <span>{{ parent.user.nickname }}</span> &nbsp;&nbsp;&nbsp;
        <span>{{ parent.create_date | mydate }}</span>
      </div>
      <span @click="replycom(parent)">回复</span>
    </div>
    <div class="bottom">{{ parent.content }}</div>
  </div>
</template>

<script>
import { mydate } from "@/utils/myfilters.js";

export default {
  props: ["parent"],
  name: "item",
  filters: {
    mydate,
  },
  methods: {
    replycom(data) {
      this.$emit("sentcom", data);
    },
  },
};
</script>

<style lang="less" scoped>
.commentItem {
  border: 1px solid #ccc;
  padding: 5px;
  margin-top: 10px;
  .top {
    font-size: 12px;
    color: #aaa;
    display: flex;
    justify-content: space-between;
  }
  .bottom {
    font-size: 13px;
    line-height: 40px;
  }
}
</style>
